package com.weishaoying.thrift.learn.annotation;

import org.apache.zookeeper.data.Stat;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;

public class Main implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    public static void main(String[] args) {
        System.out.println("-----begin");
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("server-anno.xml");
        Object dog = beanFactory.getBean("dog");
        System.out.println("dog = " + dog);



//        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class);
//
//
//        Arrays.stream(context.getBeanDefinitionNames()).forEach(System.out::println);
//
        if (2 > 1) return;

//        TestRequest request = (TestRequest) context.getBean("testRequest");
//        System.out.println(request);
//        TestService service = (TestService) context.getBean("testService");
//        System.out.println("service = " + service);
//        System.out.println("-----ApplicationContext started");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        Main.applicationContext = applicationContext;
    }
}
